package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.WeightRecord;
import com.example.diethealthsystem.repository.WeightRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class WeightRecordService {

    private final WeightRecordRepository weightRecordRepository;

    @Autowired
    public WeightRecordService(WeightRecordRepository weightRecordRepository) {
        this.weightRecordRepository = weightRecordRepository;
    }

    public List<WeightRecord> findAll() {
        return weightRecordRepository.findAll();
    }

    public Optional<WeightRecord> findById(Long id) {
        return weightRecordRepository.findById(id);
    }

    public WeightRecord save(WeightRecord weightRecord) {
        return weightRecordRepository.save(weightRecord);
    }

    public void deleteById(Long id) {
        weightRecordRepository.deleteById(id);
    }

    public List<WeightRecord> findByUserId(Long userId) {
        return weightRecordRepository.findByUserId(userId);
    }
} 